package com.design.mode.factory;

/**
 * @ClassName Simplefactory
 * @Description  简单工厂模式
 * @Author xiongchao
 * @Date 2020/9/28 14:52
 **/
public class Simplefactory {

    public interface Producet{
        void show();
    }


    static class ProductA implements  Producet{
        @Override
        public void show() {
            System.out.println("这是产品A的业务");
        }
    }

    static class ProductB implements Producet{
        @Override
        public void show() {
            System.out.println("这是产品B的业务");
        }
    }

    static class ProductC implements Producet {
        @Override
        public void show() {
            System.out.println("这是产品C的业务");
        }
    }

    final class Const  {
        static final int PRODUCT_A = 0;
        static final int PRODUCT_B = 1;
        static final int PRODUCT_C = 2;
    }

    static class Factory {
        public static Producet makeProduct(int kind){
            switch (kind) {
                case Const.PRODUCT_A:
                    return new ProductA();
                case Const.PRODUCT_B:
                    return new ProductB();
                case Const.PRODUCT_C:
                    return new ProductC();
            }
            return null;
        }
    }

    public static void main(String[] args) {
        Factory.makeProduct(0).show();
    }
}
